angular.module('driver')
	.factory('Map', ['$localstorage', function($localstorage) {
		//window.map = bmap;
		//var bmap = new BMap.
		var o = {
			instance: null,
			geolocation: null,
			MGeocoder : null,
			location: null,
			watchId: 0,
		}

		o.setLocation = function(location) {
			$localstorage.setObject('location', location);
		};
		o.getLocation = function() {
			return $localstorage.getObject('location');
		}

		o.watchPosition = function () {
			//console.log(o.geolocation);
			o.watchId = o.geolocation.watchPosition();
		};

		o.stopWatch = function () {
			o.geolocation.clearWatch( o.watchId );
		};

		return o;
	}]);
